#pragma once
#include "VarArray.h"

template <typename REC_TYPE>
class IUserDefineDelete
{
public:
	virtual void userDefineDelete(REC_TYPE rec) = 0;
};

template <typename POINTER_TYPE>
class CPointerArray : public CVarArray<POINTER_TYPE>
{
public:
	enum CLEAR_METHOD { Delete, Free, None, UserDefine };

	CPointerArray(CLEAR_METHOD m);
	~CPointerArray() override;
	__forceinline void SetUserDefine(IUserDefineDelete<POINTER_TYPE> *udf) { m_userDefine = udf; }

	bool del(intptr_t nIndex) override;
	void clear() override;
	bool del(POINTER_TYPE rec) { return del(indexOf(rec)); }
protected:
	void selfClear();

	CLEAR_METHOD method;
	IUserDefineDelete<POINTER_TYPE> *m_userDefine;
};
